/**
 * Created by Administrator on 2017/10/17.
 */
'use strict';

/**
 * @type {*}
 */

let underscore = require('underscore');
let RestifyProxy = require('../util/RestifyProxy');
let StringUtil = require('../util/StringUtil');
let Constant = require('../model/Constant');
let baseService = require('./BaseService');
const URI = {
    RENTAL: '/order',/* 查看托盘租赁列表 */
    RENTAL_ADD: '/order/leases',/* 增加托盘租赁 */
    RENTAL_DETAIL:'/order/info/{0}',/* 查询托盘租赁详情 */
    RENTAL_PALLET:'/system/params/message/orderExpenseParam/{0}', /* 查询托盘租赁详情 */
    RENTAL_CONTRACT_LIST:'/contract/files', /* 查询托盘租赁详情合同列表 */
    RENTAL_CREATE:'/order/insertOrderLease' ,//托盘租赁新增
    CONTINUED_DETAIL:'/order/info/{0}',//订单变更记录详情
    ORDERRETURN:'/order/getOrderReturnList',
    RENEWALORDER:'/order/renewalOrderList',
    ORDERSUBLET:'/order/subletOrderList',
    EXPORT_DATA:'/order/outputOrderInfo/{0}',
    BIND:'/order/leases/getBindingSupplyListByLeaseId',
    CANBIND:'/order/leases/getCanBindingSupplyList',
    SUBMIT_BIND:'/order/leases/boundOrderLeaseSupply',
    OFFBIND:'/order/leases/relieveBinding',
    RECOVER:'/order/recoveryOrder/{0}',
    CANCLE:'/order/cancelOrder/{0}',
    SUREORDER:'/order/confirmReceipt/{0}',
    EDIT_SAVE:'/order/leases/update',
    GET_COST:'/order/leases/getCosts',
    DELETE_CM:'/contract/files/{0}'
    /* USER_DETAIL: '/users/{0}/info',
     MODIFY_USER: '/users/info',
     DELETE_USER: '/users',
     ENABLED_USER: '/users/{0}/enable',
     DISABLED_USER: '/users/{0}/disable'*/
};

/**
 * 获取-托盘租赁列表
 * @param thiz
 * @returns {Promise}
 */
module.exports.getRentalList = function (thiz, params) {
    return baseService.get(thiz, URI.RENTAL, params);
};
/**
 * 获取-托盘租赁详情-合同信息列表
 * @param thiz
 * @returns {Promise}
 */
module.exports.getContractManagementList = function (thiz, params) {
    return baseService.get(thiz, URI.RENTAL_CONTRACT_LIST, params);
};
/** 获取托盘租赁详情 */
module.exports.getRentalDataById  = function (thiz, id) {
    return baseService.get(thiz, StringUtil.format(URI.RENTAL_DETAIL, id));
};
//恢复订单、
module.exports.getRecoverOrderById  = function (thiz, id) {
    return baseService.get(thiz, StringUtil.format(URI.RECOVER, id));
};
//废弃订单
module.exports.getCancleOrderById  = function (thiz, id) {
    return baseService.get(thiz, StringUtil.format(URI.CANCLE, id));
};
//确认收板
module.exports.getsureOrderById  = function (thiz, id) {
    return baseService.get(thiz, StringUtil.format(URI.SUREORDER, id));
};
/** 修改托盘租赁 */
module.exports.editSave = function (thiz, params) {
    return baseService.put(thiz, URI.EDIT_SAVE, params);
};

//导出订单
module.exports.getExportDataById  = function (thiz, id) {
    return baseService.get(thiz, StringUtil.format(URI.EXPORT_DATA, id));
};

/** 获取托盘租赁详情里面的托盘租金数据*/
module.exports.getPalletById  = function (thiz, id) {
    return baseService.put(thiz, StringUtil.format(URI.RENTAL_PALLET, id));
};
/** 添加托盘租赁 */
module.exports.createRental = function (thiz, params) {
    return baseService.post(thiz, URI.RENTAL_CREATE, params);
};
/** 获取托盘续租记录 */
module.exports.getContinuedDataById  = function (thiz, id) {
    return baseService.get(thiz, StringUtil.format(URI.CONTINUED_DETAIL, id));
};
/**
 * 获取-托盘续租列表
 */
module.exports.getRenewalOrderList = function (thiz, params) {
    return baseService.get(thiz, URI. RENEWALORDER, params);
};
/**
 * 获取-托盘退板列表
 */
module.exports.getOrderReturnList = function (thiz, params) {
    return baseService.get(thiz, URI.ORDERRETURN, params);
};
/**
 * 获取-托盘转租列表
 */
module.exports.getOrderSubletList = function (thiz, params) {
    return baseService.get(thiz, URI.ORDERSUBLET, params);
};
//绑定订单列表
module.exports.getBindRental  = function (thiz, params) {
    return baseService.get(thiz,URI.BIND, params);
};
module.exports.getCanBindList = function (thiz, params) {
    return baseService.get(thiz, URI.CANBIND, params);
};
module.exports.SubmitList = function (thiz, params) {
    return baseService.post(thiz, URI.SUBMIT_BIND, params);
};
//解除绑定
module.exports.getOffBindRental = function (thiz, params) {
    return baseService.post(thiz, URI.OFFBIND, params);
};
//订单金额计算
module.exports.getCost = function (thiz, params) {
    return baseService.get(thiz, URI.GET_COST, params);
};
//合同附件删除
module.exports.deleteContractManagement  = function (thiz, id) {
    return baseService.del(thiz, StringUtil.format(URI.DELETE_CM, id));
};

